package org.testfire.realm.util;

import java.io.Serializable;

/**
 * Created by IntelliJ IDEA.
 * User: Granum
 * Date: Dec 25, 2006
 * Time: 8:12:51 PM
 */
public class ParamStringBuilder implements Appendable, CharSequence, Serializable {
	private final StringBuilder m_stringBuilder = new StringBuilder();


	public ParamStringBuilder() {
	}

	public ParamStringBuilder append(String key, Object parameter){
		return this.append(key, parameter, "\"", "=", " ");
	}

	public ParamStringBuilder append(String key, Object parameter, String quote, String delimiter, String seperator){
		quote = quote == null ? "" : quote;
		delimiter = delimiter == null ? "" : delimiter;
		seperator = seperator  == null ? "" : seperator ;
		m_stringBuilder.append(seperator).append(key).append(delimiter).append(quote).append(parameter).append(quote);
		return this;
	}











	/* ================= Delegation Methods ==================*/
	public int length() {
		return m_stringBuilder.length();
	}

	public int capacity() {
		return m_stringBuilder.capacity();
	}

	public void ensureCapacity(int minimumCapacity) {
		m_stringBuilder.ensureCapacity(minimumCapacity);
	}

	public void trimToSize() {
		m_stringBuilder.trimToSize();
	}

	public void setLength(int newLength) {
		m_stringBuilder.setLength(newLength);
	}

	public char charAt(int index) {
		return m_stringBuilder.charAt(index);
	}

	public int codePointAt(int index) {
		return m_stringBuilder.codePointAt(index);
	}

	public int codePointBefore(int index) {
		return m_stringBuilder.codePointBefore(index);
	}

	public int codePointCount(int beginIndex, int endIndex) {
		return m_stringBuilder.codePointCount(beginIndex, endIndex);
	}

	public int offsetByCodePoints(int index, int codePointOffset) {
		return m_stringBuilder.offsetByCodePoints(index, codePointOffset);
	}

	public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin) {
		m_stringBuilder.getChars(srcBegin, srcEnd, dst, dstBegin);
	}

	public void setCharAt(int index, char ch) {
		m_stringBuilder.setCharAt(index, ch);
	}

	public String substring(int start) {
		return m_stringBuilder.substring(start);
	}

	public CharSequence subSequence(int start, int end) {
		return m_stringBuilder.subSequence(start, end);
	}

	public String substring(int start, int end) {
		return m_stringBuilder.substring(start, end);
	}


	public ParamStringBuilder append(Object obj) {
		m_stringBuilder.append(obj);
		return this;
	}

	public ParamStringBuilder append(String str) {
		m_stringBuilder.append(str);
		return this;
	}

	public ParamStringBuilder append(StringBuffer sb) {
		m_stringBuilder.append(sb);
		return this;
	}

	public ParamStringBuilder append(CharSequence s) {
		m_stringBuilder.append(s);
		return this;
	}

	public ParamStringBuilder append(CharSequence s, int start, int end) {
		m_stringBuilder.append(s, start, end);
		return this;
	}

	public ParamStringBuilder append(char[] str) {
		m_stringBuilder.append(str);
		return this;
	}

	public ParamStringBuilder append(char[] str, int offset, int len) {
		m_stringBuilder.append(str, offset, len);
		return this;
	}

	public ParamStringBuilder append(boolean b) {
		m_stringBuilder.append(b);
		return this;
	}

	public ParamStringBuilder append(char c) {
		m_stringBuilder.append(c);
		return this;
	}

	public ParamStringBuilder append(int i) {
		m_stringBuilder.append(i);
		return this;
	}

	public ParamStringBuilder append(long lng) {
		m_stringBuilder.append(lng);
		return this;
	}

	public ParamStringBuilder append(float f) {
		m_stringBuilder.append(f);
		return this;
	}

	public ParamStringBuilder append(double d) {
		m_stringBuilder.append(d);
		return this;
	}

	public ParamStringBuilder appendCodePoint(int codePoint) {
		m_stringBuilder.appendCodePoint(codePoint);
		return this;
	}

	public ParamStringBuilder delete(int start, int end) {
		m_stringBuilder.delete(start, end);
		return this;
	}

	public ParamStringBuilder deleteCharAt(int index) {
		m_stringBuilder.deleteCharAt(index);
		return this;
	}

	public ParamStringBuilder replace(int start, int end, String str) {
		m_stringBuilder.replace(start, end, str);
		return this;
	}

	public ParamStringBuilder insert(int index, char[] str, int offset, int len) {
		m_stringBuilder.insert(index, str, offset, len);
		return this;
	}

	public ParamStringBuilder insert(int offset, Object obj) {
		m_stringBuilder.insert(offset, obj);
		return this;
	}

	public ParamStringBuilder insert(int offset, String str) {
		m_stringBuilder.insert(offset, str);
		return this;
	}

	public ParamStringBuilder insert(int offset, char[] str) {
		m_stringBuilder.insert(offset, str);
		return this;
	}

	public ParamStringBuilder insert(int dstOffset, CharSequence s) {
		m_stringBuilder.insert(dstOffset, s);
		return this;
	}

	public ParamStringBuilder insert(int dstOffset, CharSequence s, int start, int end) {
		m_stringBuilder.insert(dstOffset, s, start, end);
		return this;
	}

	public ParamStringBuilder insert(int offset, boolean b) {
		m_stringBuilder.insert(offset, b);
		return this;
	}

	public ParamStringBuilder insert(int offset, char c) {
		m_stringBuilder.insert(offset, c);
		return this;
	}

	public ParamStringBuilder insert(int offset, int i) {
		m_stringBuilder.insert(offset, i);
		return this;
	}

	public ParamStringBuilder insert(int offset, long l) {
		m_stringBuilder.insert(offset, l);
		return this;
	}

	public ParamStringBuilder insert(int offset, float f) {
		m_stringBuilder.insert(offset, f);
		return this;
	}

	public ParamStringBuilder insert(int offset, double d) {
		m_stringBuilder.insert(offset, d);
		return this;
	}

	public int indexOf(String str) {
		return m_stringBuilder.indexOf(str);
	}

	public int indexOf(String str, int fromIndex) {
		return m_stringBuilder.indexOf(str, fromIndex);
	}

	public int lastIndexOf(String str) {
		return m_stringBuilder.lastIndexOf(str);
	}

	public int lastIndexOf(String str, int fromIndex) {
		return m_stringBuilder.lastIndexOf(str, fromIndex);
	}

	public ParamStringBuilder reverse() {
		m_stringBuilder.reverse();
		return this;
	}

	public String toString() {
		return m_stringBuilder.toString();
	}
}
